#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

using namespace std;


int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        int x, count = 0, a = 1;
        cin >> x;
        x--;
        count++;
        while (x > 0)
        {
            if (x % (2 * a) == 0)
            {
                x -= 2 * a;
                a *= 2;
                count++;
            }
            else
            {
                x -= a;
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}